using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace BeatEmUp
{
    public class Game : Microsoft.Xna.Framework.Game
    {
        public GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Map map;
        MenuComponent menu;
        ResolutionManager customResolution;


        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            customResolution = new ResolutionManager(this);
            customResolution.ChangeResolutionTo(800,600);

            Content.RootDirectory = "Content";
        }

        public void changeMapVisibleParameterTo(bool isVisible)
        {
            map.Visible = isVisible;
            map.GetActiveGameField().Visible = isVisible;
        }
        public void changeMapEnableParameterTo(bool isEnable)
        {
            map.Enabled = isEnable;
            map.GetActiveGameField().Enabled = isEnable;
        }
        
        protected override void Initialize()
        {
            customResolution = new ResolutionManager(this);
            map = new Map(this);
            menu = new MenuComponent(this);
            

            this.Components.Add(customResolution);
            this.Components.Add(map);
            this.Components.Add(menu);

            base.Initialize();
        }

        public SpriteBatch SpriteBatch
        {
            get { return this.spriteBatch; }
        }


        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);            
        }

        protected override void UnloadContent(){}


        protected override void Update(GameTime gameTime)
        {
           
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            base.Update(gameTime);
        }
        
       

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();          
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
